package com.moli.iov.admin.web.controller;

import com.moli.iov.admin.model.vo.req.DictDataQueryByTypeVo;
import com.moli.iov.admin.service.DictDataService;
import com.moli.iov.base.model.dto.DictDataQueryByTypeDto;
import com.moli.iov.base.model.po.DictData;
import com.moli.iov.rest.RestResponse;
import com.moli.iov.util.JsonUtils;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 监控
 * @author whl
 */
@Slf4j
@RequestMapping("/dict")
@RestController
public class DictController  {

    @Resource
    private DictDataService dictDataService;

    /**
     * 根据字典类型获取字典数据列表 树
     * @param dictDataQueryByTypeVo
     * @return
     */
    @PostMapping("/listDictTreeByType")
    public RestResponse<Map<String, List<DictData>>> listDictTreeByType(@RequestBody DictDataQueryByTypeVo dictDataQueryByTypeVo){
        try {
            RestResponse<Map<String, List<DictData>>> mapRestResponse = dictDataService
                .listDictTreeByType(dictDataQueryByTypeVo);
            return mapRestResponse;
        }catch (Exception e){
            log.error("调用数据字典服务失败",e.getMessage());
            return RestResponse.failure("查询失败");
        }
    }

}
